package com.qing.demo.netty.server;

import cn.hutool.json.JSONUtil;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.socket.SocketChannel;


/**
 * @author caozhipeng
 * @date 2025/7/25
 */
public class MyServerHandler extends ChannelInboundHandlerAdapter {

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        SocketChannel socketChannel=(SocketChannel)ctx.channel();
        System.out.println("链接报告开始");
        System.out.println("链接报告信息：有一个客户端链接到本地服务器");
        System.out.println("链接报告IP:"+ socketChannel.localAddress().getHostString());
        System.out.println("链接报告端口:"+ socketChannel.localAddress().getPort());


    }

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        System.out.println("服务器端接收消息："+msg);
    }

}
